<?php
declare (strict_types = 1);
namespace app\user\model\user;

use think\facade\Event;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;

/**
 * 定义用户余额模型
 */
class Bcard extends BaseModel
{
    use softDelete;
    /**
     * 表名
     * @var string
     */
    protected $name = 'user_bcard';

    /**
     * 设置自动写入时间
     * @var boolean
     */
    protected $autoWriteTimestamp = true;

    /**
     * 定义字段类型
     * @var array
     */
    protected $type = [
        'id'            => 'integer',
        'user_id'       => 'integer',
        'balance'       => 'float',
        'create_time'   => 'integer',
        'delete_time'   => 'integer',
    ];

    /**
     * 定义表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 设置状态查询条件
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-03-10
     * @param    [type]                         $query  [description]
     * @param    integer                        $status 查询条件值
     */
    public function scopeAlipay($query)
    {
        $query->where('user_id', request()->mid)->where('type', 'alipay');
    }


}
